
from pluginHelper import *


#
# severity for this plugin:
SEVERITY = 1

#
# This is a scanner function that can scan the file line-by-line.
# The function is called once for each line in the input file. THe filename
# and current line number is passed to the function. The function returns
# a boolean value indicating whether it wants more input (True), or whether
# it does not care any moer about this file (False).
#
# errors are reported using reportError(line, col)
#
def scanLine(self, line, filename, currentLine):
	ln = line.lower()
	if 'todo' in ln:
		# report a problem. arguments are line, column:
		out("Found TODO in file %s:%d ('%s')" % (filename, currentLine, line))
		reportError(currentLine, ln.index('todo'), SEVERITY)
	
	# scan the entire file: there may be more than one occurance of the error in a single file:
	return True




#
# Set the scan function, along with it's type:
if __name__ == "__main__":
	#
	# Describe the plugin:
	init()
	describePlugin('todo','scanner', 'Checks for the string "todo" in files. This usually indicates half-baked code.')
	setScanFunction(SCANNER_TYPE_LINE_BY_LINE, scanLine)


